#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2024/9/6 11:11
# @File           : __init__
# @IDE            : PyCharm
# @desc           : 描述

from sqlalchemy.ext.asyncio import AsyncSession
from core.crud import DalBase
from . import models, schemas


class RebutDal(DalBase):

    def __init__(self, db: AsyncSession):
        super(RebutDal, self).__init__()
        self.db = db
        self.model = models.DCRebut
        self.schema = schemas.RebutSimpleOut

    async def get_select_datas(self, rebut_type, rebut_form_no, before_status):
        values = []
        if rebut_type == "QAR":
            if before_status == "检验中":
                values = ["已发布"]
            elif before_status == "委托中":
                values = ["检验中", "已发布"]
            elif before_status == "检验完成":
                values = ["检验中", "委托中", "已发布"]
            elif before_status == "归档":
                values = ["检验完成", "检验中", "委托中", "已发布"]
        elif rebut_type == "ASR":
            if before_status == "检验中":
                values = ["计划中"]
            elif before_status == "审核中":
                values = ["检验中", "计划中"]
            elif before_status == "归档":
                values = ["审核中", "检验中", "计划中"]
        elif rebut_type in ["PCLR", "NDT"]:
            if before_status == "实验中":
                values = ["计划中"]
            elif before_status == "审核中":
                values = ["实验中", "计划中"]
            elif before_status == "归档":
                values = ["审核中", "实验中", "计划中"]
        return [{'label': i, 'value': i} for i in values]